import java.util.Scanner;

public class Main1063 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int s = 0;
        int c = 0;
        for (int i = n; i <= m; i++) {
            c = 0;
            for (int j = 2; j <= i - 1; j++) {
                if (i % j == 0) {
                    c++;
                    break;
                }
            }
            if (c == 0 && i >= 2) {
                s++;
            }
        }
        System.out.println(s);
    }
}
